package com.xzlf.controller;

import com.xzlf.service.DemoService;
import com.xzlf.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @Autowired
    private DemoService demoService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/test")
    public String test(){
        System.out.println("============执行了DemoController.test================");
        return String.format("服务器端口： %s", serverPort);
    }

    @GetMapping("/setStr")
    public R setStr(String str) {
        demoService.setStr(str);
        return R.ok();
    }

    @GetMapping("/getStr")
    public R getStr() {
        return R.ok(demoService.getStr());
    }

    @GetMapping("/bufSize")
    public R bufSize() {
        return R.ok(demoService.getBuffersize());
    }

    @GetMapping("/add")
    public R add(String str) {
        demoService.add(str);
        return R.ok();
    }

    @GetMapping("/pop")
    public R pop() {
        return R.ok(demoService.pop());
    }
}
